package people;
import java.util.ArrayList;

public class CollectiveIdentity {

	private String name;
	private ArrayList<Object> identities;
	
	public CollectiveIdentity(String name) {
		this.name = name;
		identities = new ArrayList<Object>();
	}

	public void add(Object person) {
		identities.add(person);
	}

	public String getSelfIntroduction() {
		return "Here is who we are: " + name + " " + getIdentityString();
	}
	
	public String getName() {
		return name;
	}
	
	public String getIdentityString() {
		String identityString = "(";
		for (Object object : identities.toArray()) {
			if (object instanceof Person) {
				Person p = (Person)object;
				identityString += p.getName();
			}
			else {
				CollectiveIdentity ci = (CollectiveIdentity)object;
				identityString += ci.getName() + " " + ci.getIdentityString();
			}
			identityString += ", ";
		}
		identityString = identityString.substring(0, identityString.length() - 2);
		identityString += ")";
		
		return identityString;
	}

}
